<?php
/**
 * Created by PhpStorm.
 * User: aa
 * Date: 2019/9/3
 * Time: 19:31
 */

class Cookie
{
    public static function set($key, $value, $expire=3600*24, $path='', $domain='') {
        setcookie($key, $value, $expire);
    }

    public static function get($key='', $default = '') {
        if(is_numeric($key)){
            return false;
        }
        if($key=='') {
            return $_COOKIE;
        } else {
            return $_COOKIE[$key] ?? $default;
        }
    }

    public static function unset($key){
        if(is_numeric($key)){
            return false;
        }
        if(isset($_COOKIE[$key])) {
            setcookie($key, "", time()-3600);
        }
    }

}